class Solution {
public:
    TreeNode* invertTree(TreeNode* root) {
        if(root==nullptr) return nullptr;
        TreeNode*newright=invertTree(root->left);
        TreeNode*newleft=invertTree(root->right);
        root->left=newleft;
        root->right=newright;
        return root;

    }
};